import { ApiModel } from '@/api/system/sysapi/ApiModel'
import { reactive } from 'vue'

export default function useBaseModel() {
    //表单绑定的数据
    const addModel = reactive<ApiModel>({
        id: '',
        type: '',
        parent_id: '',
        description: '',
        path: '',
        method: ''
    })
    //表单验证规则
    const rules = reactive({
        parent_id: [
            {
                trigger: 'blur',
                required: true,
                message: '请选择父API'
            }
        ],
        description: [
            {
                trigger: 'blur',
                required: true,
                message: '请填写API描述'
            },
            { min: 2, max: 255, message: '长度为2-255个字符', trigger: 'blur' }
        ]
        // path: [
        //     {
        //         trigger: 'blur',
        //         required: true,
        //         message: '请填写path'
        //     }
        // ],
        // method: [
        //     {
        //         trigger: 'blur',
        //         required: true,
        //         message: '请填写API方法'
        //     }
        // ]
    })
    return {
        addModel,
        rules
    }
}
